

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>federatedml.util.param_checker &mdash; FATE 1.0 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../../../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
        <script type="text/javascript" src="../../../_static/jquery.js"></script>
        <script type="text/javascript" src="../../../_static/underscore.js"></script>
        <script type="text/javascript" src="../../../_static/doctools.js"></script>
        <script type="text/javascript" src="../../../_static/language_data.js"></script>
    
    <script type="text/javascript" src="../../../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../../../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../../../index.html" class="icon icon-home"> FATE
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <!-- Local TOC -->
              <div class="local-toc"></div>
            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../../index.html">FATE</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../../../index.html">Docs</a> &raquo;</li>
        
          <li><a href="../../index.html">Module code</a> &raquo;</li>
        
      <li>federatedml.util.param_checker</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <h1>Source code for federatedml.util.param_checker</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python    </span>
<span class="c1"># -*- coding: utf-8 -*-</span>
<span class="c1">#</span>
<span class="c1">#  Copyright 2019 The FATE Authors. All Rights Reserved.</span>
<span class="c1">#</span>
<span class="c1">#  Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);</span>
<span class="c1">#  you may not use this file except in compliance with the License.</span>
<span class="c1">#  You may obtain a copy of the License at</span>
<span class="c1">#</span>
<span class="c1">#      http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1">#  Unless required by applicable law or agreed to in writing, software</span>
<span class="c1">#  distributed under the License is distributed on an &quot;AS IS&quot; BASIS,</span>
<span class="c1">#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span>
<span class="c1">#  See the License for the specific language governing permissions and</span>
<span class="c1">#  limitations under the License.</span>
<span class="c1">#</span>
<span class="c1">################################################################################</span>
<span class="c1">#</span>
<span class="c1">#</span>
<span class="c1">################################################################################</span>
<span class="kn">from</span> <span class="nn">arch.api.utils</span> <span class="k">import</span> <span class="n">log_utils</span>
<span class="kn">from</span> <span class="nn">federatedml.param</span> <span class="k">import</span> <span class="n">param</span>
<span class="kn">from</span> <span class="nn">federatedml.util</span> <span class="k">import</span> <span class="n">consts</span>
<span class="kn">from</span> <span class="nn">federatedml.util.param_extract</span> <span class="k">import</span> <span class="n">ParamExtract</span>
<span class="kn">import</span> <span class="nn">inspect</span>
<span class="kn">import</span> <span class="nn">json</span>

<span class="n">LOGGER</span> <span class="o">=</span> <span class="n">log_utils</span><span class="o">.</span><span class="n">getLogger</span><span class="p">()</span>


<div class="viewcode-block" id="DataIOParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.DataIOParamChecker">[docs]</a><span class="k">class</span> <span class="nc">DataIOParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="DataIOParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.DataIOParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">dataio_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">dataio_param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;DataIOParam&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;dataio_param </span><span class="si">{}</span><span class="s2"> not supported, should be DataIOParam object&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">dataio_param</span><span class="p">))</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;dataio param&#39;s&quot;</span>

        <span class="n">dataio_param</span><span class="o">.</span><span class="n">input_format</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">input_format</span><span class="p">,</span>
                                                           <span class="p">[</span><span class="s2">&quot;dense&quot;</span><span class="p">,</span> <span class="s2">&quot;sparse&quot;</span><span class="p">,</span> <span class="s2">&quot;tag&quot;</span><span class="p">],</span>
                                                           <span class="n">descr</span><span class="p">)</span>

        <span class="n">dataio_param</span><span class="o">.</span><span class="n">output_format</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">output_format</span><span class="p">,</span>
                                                            <span class="p">[</span><span class="s2">&quot;dense&quot;</span><span class="p">,</span> <span class="s2">&quot;sparse&quot;</span><span class="p">],</span>
                                                            <span class="n">descr</span><span class="p">)</span>

        <span class="n">dataio_param</span><span class="o">.</span><span class="n">data_type</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">data_type</span><span class="p">,</span>
                                                        <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;int64&quot;</span><span class="p">,</span> <span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;float64&quot;</span><span class="p">,</span> <span class="s2">&quot;str&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">],</span>
                                                        <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">missing_fill</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s1">&#39;bool&#39;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;dataio param&#39;s missing_fill </span><span class="si">{}</span><span class="s2"> not supported&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">missing_fill</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">dataio_param</span><span class="o">.</span><span class="n">missing_fill_method</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">dataio_param</span><span class="o">.</span><span class="n">missing_fill_method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">missing_fill_method</span><span class="p">,</span>
                                                                      <span class="p">[</span><span class="s1">&#39;min&#39;</span><span class="p">,</span> <span class="s1">&#39;max&#39;</span><span class="p">,</span> <span class="s1">&#39;mean&#39;</span><span class="p">,</span> <span class="s1">&#39;designated&#39;</span><span class="p">],</span>
                                                                      <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">dataio_param</span><span class="o">.</span><span class="n">outlier_replace_method</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">dataio_param</span><span class="o">.</span><span class="n">outlier_replace_method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">outlier_replace_method</span><span class="p">,</span>
                                                                         <span class="p">[</span><span class="s1">&#39;min&#39;</span><span class="p">,</span> <span class="s1">&#39;max&#39;</span><span class="p">,</span> <span class="s1">&#39;mean&#39;</span><span class="p">,</span> <span class="s1">&#39;designated&#39;</span><span class="p">],</span>
                                                                         <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">with_label</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s1">&#39;bool&#39;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;dataio param&#39;s with_label </span><span class="si">{}</span><span class="s2"> not supported&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">with_label</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">dataio_param</span><span class="o">.</span><span class="n">with_label</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">label_idx</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;long&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;dataio param&#39;s label_idx </span><span class="si">{}</span><span class="s2"> not supported&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">label_idx</span><span class="p">))</span>

            <span class="n">dataio_param</span><span class="o">.</span><span class="n">label_type</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">dataio_param</span><span class="o">.</span><span class="n">label_type</span><span class="p">,</span>
                                                             <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;int64&quot;</span><span class="p">,</span> <span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;float64&quot;</span><span class="p">,</span> <span class="s2">&quot;str&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">],</span>
                                                             <span class="n">descr</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="ObjectiveParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.ObjectiveParamChecker">[docs]</a><span class="k">class</span> <span class="nc">ObjectiveParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="ObjectiveParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.ObjectiveParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">objective_param</span><span class="p">,</span> <span class="n">task_type</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">objective_param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;ObjectiveParam&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;objective param </span><span class="si">{}</span><span class="s2"> not supportd, should be ObjectiveParam object&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">objective_param</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;objective param&#39;s&quot;</span>

        <span class="k">if</span> <span class="n">task_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">CLASSIFICATION</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">REGRESSION</span><span class="p">]:</span>
            <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span><span class="p">,</span>
                                                               <span class="p">[</span><span class="s2">&quot;cross_entropy&quot;</span><span class="p">,</span> <span class="s2">&quot;lse&quot;</span><span class="p">,</span> <span class="s2">&quot;lae&quot;</span><span class="p">,</span> <span class="s2">&quot;huber&quot;</span><span class="p">,</span> <span class="s2">&quot;fair&quot;</span><span class="p">,</span>
                                                                <span class="s2">&quot;log_cosh&quot;</span><span class="p">,</span> <span class="s2">&quot;tweedie&quot;</span><span class="p">],</span>
                                                               <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">task_type</span> <span class="o">==</span> <span class="n">consts</span><span class="o">.</span><span class="n">CLASSIFICATION</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="o">!=</span> <span class="s2">&quot;cross_entropy&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;objective param&#39;s objective </span><span class="si">{}</span><span class="s2"> not supported&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span><span class="p">))</span>

        <span class="k">elif</span> <span class="n">task_type</span> <span class="o">==</span> <span class="n">consts</span><span class="o">.</span><span class="n">REGRESSION</span><span class="p">:</span>
            <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span><span class="p">,</span>
                                                               <span class="p">[</span><span class="s2">&quot;lse&quot;</span><span class="p">,</span> <span class="s2">&quot;lae&quot;</span><span class="p">,</span> <span class="s2">&quot;huber&quot;</span><span class="p">,</span> <span class="s2">&quot;fair&quot;</span><span class="p">,</span> <span class="s2">&quot;log_cosh&quot;</span><span class="p">,</span> <span class="s2">&quot;tweedie&quot;</span><span class="p">],</span>
                                                               <span class="n">descr</span><span class="p">)</span>

            <span class="n">params</span> <span class="o">=</span> <span class="n">objective_param</span><span class="o">.</span><span class="n">params</span>
            <span class="k">if</span> <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;huber&quot;</span><span class="p">,</span> <span class="s2">&quot;fair&quot;</span><span class="p">,</span> <span class="s2">&quot;tweedie&quot;</span><span class="p">]:</span>
                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">params</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s1">&#39;list&#39;</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">params</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;objective param&#39;s params </span><span class="si">{}</span><span class="s2"> not supported, should be non-empty list&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">params</span><span class="p">))</span>

                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">params</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;objective param&#39;s params[0] </span><span class="si">{}</span><span class="s2"> not supported&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">objective_param</span><span class="o">.</span><span class="n">params</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>

                <span class="k">if</span> <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="o">==</span> <span class="s1">&#39;tweedie&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">params</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;</span> <span class="mi">1</span> <span class="ow">or</span> <span class="n">params</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;=</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;in tweedie regression, objective params[0] should betweend [1, 2)&quot;</span><span class="p">)</span>

                <span class="k">if</span> <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span> <span class="o">==</span> <span class="s1">&#39;fair&#39;</span> <span class="ow">or</span> <span class="s1">&#39;huber&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">params</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&lt;=</span> <span class="mf">0.0</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;in </span><span class="si">{}</span><span class="s2"> regression, objective params[0] should greater than 0.0&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">objective_param</span><span class="o">.</span><span class="n">objective</span><span class="p">))</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="EncryptParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EncryptParamChecker">[docs]</a><span class="k">class</span> <span class="nc">EncryptParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="EncryptParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EncryptParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">encrypt_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">encrypt_param</span><span class="o">.</span><span class="n">method</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;encrypt_param&#39;s method </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">encrypt_param</span><span class="o">.</span><span class="n">method</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">user_input</span> <span class="o">=</span> <span class="n">encrypt_param</span><span class="o">.</span><span class="n">method</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">user_input</span> <span class="o">==</span> <span class="s1">&#39;paillier&#39;</span><span class="p">:</span>
                <span class="n">encrypt_param</span><span class="o">.</span><span class="n">method</span> <span class="o">=</span> <span class="n">consts</span><span class="o">.</span><span class="n">PAILLIER</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">encrypt_param</span><span class="o">.</span><span class="n">key_length</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;encrypt_param&#39;s key_length </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">encrypt_param</span><span class="o">.</span><span class="n">key_length</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">encrypt_param</span><span class="o">.</span><span class="n">key_length</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;encrypt_param&#39;s key_length must be greater or equal to 1&quot;</span><span class="p">)</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish encrypt parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="EncryptedModeCalculatorParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EncryptedModeCalculatorParamChecker">[docs]</a><span class="k">class</span> <span class="nc">EncryptedModeCalculatorParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="EncryptedModeCalculatorParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EncryptedModeCalculatorParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">encrypted_mode_calculator</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">encrypted_mode_calculator</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;EncryptedModeCalculatorParam&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;param class not match EncryptedModeCalculatorParam&quot;</span><span class="p">)</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;encrypted_mode_calculator param&quot;</span>
        <span class="n">encrypted_mode_calculator</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">encrypted_mode_calculator</span><span class="o">.</span><span class="n">mode</span><span class="p">,</span>
                                                                <span class="p">[</span><span class="s2">&quot;strict&quot;</span><span class="p">,</span> <span class="s2">&quot;fast&quot;</span><span class="p">,</span> <span class="s2">&quot;balance&quot;</span><span class="p">],</span>
                                                                <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">encrypted_mode_calculator</span><span class="o">.</span><span class="n">mode</span> <span class="o">==</span> <span class="s2">&quot;balance&quot;</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">encrypted_mode_calculator</span><span class="o">.</span><span class="n">re_encrypted_rate</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">,</span> <span class="s2">&quot;float&quot;</span><span class="p">]:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;re_encrypted_rate should be a numeric number&quot;</span><span class="p">)</span>

        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="SampleParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.SampleParamChecker">[docs]</a><span class="k">class</span> <span class="nc">SampleParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="SampleParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.SampleParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">sample_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">sample_param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;SampleParam&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;sample param </span><span class="si">{}</span><span class="s2"> not supported, should be SampleParam object&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">sample_param</span><span class="p">))</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;sample param&quot;</span>
        <span class="n">sample_param</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">sample_param</span><span class="o">.</span><span class="n">mode</span><span class="p">,</span>
                                                   <span class="p">[</span><span class="s2">&quot;random&quot;</span><span class="p">,</span> <span class="s2">&quot;stratified&quot;</span><span class="p">],</span>
                                                   <span class="n">descr</span><span class="p">)</span>

        <span class="n">sample_param</span><span class="o">.</span><span class="n">method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">sample_param</span><span class="o">.</span><span class="n">method</span><span class="p">,</span>
                                                     <span class="p">[</span><span class="s2">&quot;upsample&quot;</span><span class="p">,</span> <span class="s2">&quot;downsample&quot;</span><span class="p">],</span>
                                                     <span class="n">descr</span><span class="p">)</span>

        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="DecisionTreeParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.DecisionTreeParamChecker">[docs]</a><span class="k">class</span> <span class="nc">DecisionTreeParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="DecisionTreeParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.DecisionTreeParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">tree_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;DecisionTreeParam&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;decision tree param </span><span class="si">{}</span><span class="s2"> not supported, should be DecisionTreeParam object&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">tree_param</span><span class="p">))</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;decision tree param&quot;</span>

        <span class="n">tree_param</span><span class="o">.</span><span class="n">criterion_method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">criterion_method</span><span class="p">,</span>
                                                             <span class="p">[</span><span class="s2">&quot;xgboost&quot;</span><span class="p">],</span>
                                                             <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">criterion_params</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;list&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s criterion_params </span><span class="si">{}</span><span class="s2"> not supported, should be list&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">tree_param</span><span class="o">.</span><span class="n">criterion_params</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">criterion_params</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decisition tree param&#39;s criterio_params should be non empty&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">criterion_params</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">,</span> <span class="s2">&quot;float&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s criterion_params element shoubld be numeric&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">max_depth</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s max_depth </span><span class="si">{}</span><span class="s2"> not supported, should be integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">tree_param</span><span class="o">.</span><span class="n">max_depth</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">tree_param</span><span class="o">.</span><span class="n">max_depth</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s max_depth should be positive integer, no less than 1&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">min_sample_split</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s min_sample_split </span><span class="si">{}</span><span class="s2"> not supported, should be integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">tree_param</span><span class="o">.</span><span class="n">min_sample_split</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">min_impurity_split</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">,</span> <span class="s2">&quot;float&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s min_impurity_split </span><span class="si">{}</span><span class="s2"> not supported, should be numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">tree_param</span><span class="o">.</span><span class="n">min_impurity_split</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">min_leaf_node</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s min_leaf_node </span><span class="si">{}</span><span class="s2"> not supported, should be integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">tree_param</span><span class="o">.</span><span class="n">min_leaf_node</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">max_split_nodes</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">tree_param</span><span class="o">.</span><span class="n">max_split_nodes</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s max_split_nodes </span><span class="si">{}</span><span class="s2"> not supported, &quot;</span> <span class="o">+</span> \
                             <span class="s2">&quot;should be positive integer between 1 and </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">max_split_nodes</span><span class="p">,</span>
                                                                                  <span class="n">consts</span><span class="o">.</span><span class="n">MAX_SPLIT_NODES</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">n_iter_no_change</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s n_iter_no_change </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">tree_param</span><span class="o">.</span><span class="n">n_iter_no_change</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">tol</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;decision tree param&#39;s tol </span><span class="si">{}</span><span class="s2"> not supported, should be numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">tol</span><span class="p">))</span>

        <span class="n">tree_param</span><span class="o">.</span><span class="n">feature_importance_type</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">tree_param</span><span class="o">.</span><span class="n">feature_importance_type</span><span class="p">,</span>
                                                                    <span class="p">[</span><span class="s2">&quot;split&quot;</span><span class="p">,</span> <span class="s2">&quot;gain&quot;</span><span class="p">],</span>
                                                                    <span class="n">descr</span><span class="p">)</span>

        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="BoostingTreeParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.BoostingTreeParamChecker">[docs]</a><span class="k">class</span> <span class="nc">BoostingTreeParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="BoostingTreeParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.BoostingTreeParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">boost_param</span><span class="p">):</span>
        <span class="n">DecisionTreeParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">tree_param</span><span class="p">)</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;boosting tree param&#39;s&quot;</span>

        <span class="k">if</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">task_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">CLASSIFICATION</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">REGRESSION</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s task_type </span><span class="si">{}</span><span class="s2"> not supported, should be </span><span class="si">{}</span><span class="s2"> or </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">boost_param</span><span class="o">.</span><span class="n">task_type</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">CLASSIFICATION</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">REGRESSION</span><span class="p">))</span>

        <span class="n">ObjectiveParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">objective_param</span><span class="p">,</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">task_type</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s learning_rate </span><span class="si">{}</span><span class="s2"> not supported, should be numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">boost_param</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">num_trees</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">num_trees</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s num_trees </span><span class="si">{}</span><span class="s2"> not supported, should be postivie integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">boost_param</span><span class="o">.</span><span class="n">num_trees</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">subsample_feature_rate</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> \
                <span class="n">boost_param</span><span class="o">.</span><span class="n">subsample_feature_rate</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">subsample_feature_rate</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s subsample_feature_rate should be a numeric number between 0 and 1&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">n_iter_no_change</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s n_iter_no_change </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">boost_param</span><span class="o">.</span><span class="n">n_iter_no_change</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">tol</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s tol </span><span class="si">{}</span><span class="s2"> not supported, should be numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">tol</span><span class="p">))</span>

        <span class="n">EncryptParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">encrypt_param</span><span class="p">)</span>

        <span class="n">boost_param</span><span class="o">.</span><span class="n">quantile_method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">quantile_method</span><span class="p">,</span>
                                                             <span class="p">[</span><span class="s2">&quot;bin_by_data_block&quot;</span><span class="p">,</span> <span class="s2">&quot;bin_by_sample_data&quot;</span><span class="p">],</span>
                                                             <span class="s2">&quot;boosting tree param&#39;s quantile_method&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">bin_num</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">bin_num</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;boosting tree param&#39;s bin_num </span><span class="si">{}</span><span class="s2"> not supported, should be positive integer greater than 1&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">boost_param</span><span class="o">.</span><span class="n">bin_num</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">bin_gap</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;boosting tree param&#39;s bin_gap </span><span class="si">{}</span><span class="s2"> not supported, should be numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">bin_gap</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">quantile_method</span> <span class="o">==</span> <span class="s2">&quot;bin_by_sample_data&quot;</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">boost_param</span><span class="o">.</span><span class="n">bin_sample_num</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">boost_param</span><span class="o">.</span><span class="n">bin_sample_num</span> <span class="o">&lt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;boosting tree param&#39;s sample_num </span><span class="si">{}</span><span class="s2"> not supported, should be positive integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">boost_param</span><span class="o">.</span><span class="n">bin_sample_num</span><span class="p">))</span>

        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="EncodeParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EncodeParamChecker">[docs]</a><span class="k">class</span> <span class="nc">EncodeParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="EncodeParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EncodeParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">encode_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">encode_param</span><span class="o">.</span><span class="n">salt</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;encode param&#39;s salt </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">encode_param</span><span class="o">.</span><span class="n">salt</span><span class="p">))</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;encode param&#39;s &quot;</span>

        <span class="n">encode_param</span><span class="o">.</span><span class="n">encode_method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">encode_param</span><span class="o">.</span><span class="n">encode_method</span><span class="p">,</span>
                                                            <span class="p">[</span><span class="s2">&quot;none&quot;</span><span class="p">,</span> <span class="s2">&quot;md5&quot;</span><span class="p">,</span> <span class="s2">&quot;sha1&quot;</span><span class="p">,</span> <span class="s2">&quot;sha224&quot;</span><span class="p">,</span> <span class="s2">&quot;sha256&quot;</span><span class="p">,</span> <span class="s2">&quot;sha384&quot;</span><span class="p">,</span>
                                                             <span class="s2">&quot;sha512&quot;</span><span class="p">],</span>
                                                            <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">encode_param</span><span class="o">.</span><span class="n">base64</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;encode param&#39;s base64 </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">encode_param</span><span class="o">.</span><span class="n">base64</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish encode parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="IntersectParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.IntersectParamChecker">[docs]</a><span class="k">class</span> <span class="nc">IntersectParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="IntersectParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.IntersectParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">intersect_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;intersect param&#39;s&quot;</span>

        <span class="n">intersect_param</span><span class="o">.</span><span class="n">intersect_method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">intersect_method</span><span class="p">,</span>
                                                                  <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">RSA</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">RAW</span><span class="p">],</span>
                                                                  <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">random_bit</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;intersect param&#39;s random_bit </span><span class="si">{}</span><span class="s2"> not supported, should be positive integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">intersect_param</span><span class="o">.</span><span class="n">random_bit</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">is_send_intersect_ids</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;intersect param&#39;s is_send_intersect_ids </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">intersect_param</span><span class="o">.</span><span class="n">is_send_intersect_ids</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">is_get_intersect_ids</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;intersect param&#39;s is_get_intersect_ids </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">intersect_param</span><span class="o">.</span><span class="n">is_get_intersect_ids</span><span class="p">))</span>

        <span class="n">intersect_param</span><span class="o">.</span><span class="n">join_role</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">join_role</span><span class="p">,</span>
                                                           <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">GUEST</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">HOST</span><span class="p">],</span>
                                                           <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">with_encode</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;intersect param&#39;s with_encode </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">intersect_param</span><span class="o">.</span><span class="n">with_encode</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">only_output_key</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;intersect param&#39;s only_output_key </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">intersect_param</span><span class="o">.</span><span class="n">is_send_intersect_ids</span><span class="p">))</span>

        <span class="n">EncodeParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">intersect_param</span><span class="o">.</span><span class="n">encode_params</span><span class="p">)</span>
        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish intersect parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="PredictParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.PredictParamChecker">[docs]</a><span class="k">class</span> <span class="nc">PredictParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="PredictParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.PredictParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">predict_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">predict_param</span><span class="o">.</span><span class="n">with_proba</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;predict param&#39;s with_proba </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">predict_param</span><span class="o">.</span><span class="n">with_proba</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">predict_param</span><span class="o">.</span><span class="n">threshold</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;predict param&#39;s predict_param </span><span class="si">{}</span><span class="s2"> not supported, should be float or int&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">predict_param</span><span class="o">.</span><span class="n">threshold</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish predict parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="OneVsRestChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.OneVsRestChecker">[docs]</a><span class="k">class</span> <span class="nc">OneVsRestChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="OneVsRestChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.OneVsRestChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">one_vs_rest_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">one_vs_rest_param</span><span class="o">.</span><span class="n">has_arbiter</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;one_vs_rest param&#39;s has_arbiter </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">one_vs_rest_param</span><span class="o">.</span><span class="n">with_proba</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish one_vs_rest parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="EvaluateParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EvaluateParamChecker">[docs]</a><span class="k">class</span> <span class="nc">EvaluateParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="EvaluateParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.EvaluateParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">evaluate_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">metrics</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;list&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;evaluate param&#39;s metrics </span><span class="si">{}</span><span class="s2"> not supported, should be list&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">metrics</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;evaluate param&#39;s metrics&quot;</span>
            <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">metric</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">metrics</span><span class="p">):</span>
                <span class="n">evaluate_param</span><span class="o">.</span><span class="n">metrics</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">metric</span><span class="p">,</span>
                                                                     <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">AUC</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">KS</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">LIFT</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">PRECISION</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">RECALL</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">ACCURACY</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">EXPLAINED_VARIANCE</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">MEAN_ABSOLUTE_ERROR</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">MEAN_SQUARED_ERROR</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">MEAN_SQUARED_LOG_ERROR</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">MEDIAN_ABSOLUTE_ERROR</span><span class="p">,</span>
                                                                      <span class="n">consts</span><span class="o">.</span><span class="n">R2_SCORE</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">ROOT_MEAN_SQUARED_ERROR</span><span class="p">],</span>
                                                                     <span class="n">descr</span><span class="p">)</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;evaluate param&#39;s &quot;</span>

        <span class="n">evaluate_param</span><span class="o">.</span><span class="n">classi_type</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">classi_type</span><span class="p">,</span>
                                                            <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">BINARY</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">MULTY</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">REGRESSION</span><span class="p">],</span>
                                                            <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">pos_label</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;str&quot;</span><span class="p">,</span> <span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;evaluate param&#39;s pos_label </span><span class="si">{}</span><span class="s2"> not supported, should be str or float or int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">evaluate_param</span><span class="o">.</span><span class="n">pos_label</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">thresholds</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;list&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;evaluate param&#39;s thresholds </span><span class="si">{}</span><span class="s2"> not supported, should be list&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">evaluate_param</span><span class="o">.</span><span class="n">thresholds</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">threshold</span> <span class="ow">in</span> <span class="n">evaluate_param</span><span class="o">.</span><span class="n">thresholds</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">threshold</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;threshold </span><span class="si">{}</span><span class="s2"> in evaluate param&#39;s thresholds not supported, should be positive integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">threshold</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish evaluation parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="WorkFlowParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.WorkFlowParamChecker">[docs]</a><span class="k">class</span> <span class="nc">WorkFlowParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="WorkFlowParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.WorkFlowParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">workflow_param</span><span class="p">):</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;workflow param&#39;s &quot;</span>

        <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span><span class="p">,</span>
                                                       <span class="p">[</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="s1">&#39;predict&#39;</span><span class="p">,</span> <span class="s1">&#39;cross_validation&#39;</span><span class="p">,</span>
                                                        <span class="s1">&#39;intersect&#39;</span><span class="p">,</span> <span class="s1">&#39;binning&#39;</span><span class="p">,</span> <span class="s1">&#39;feature_select&#39;</span><span class="p">,</span> <span class="s1">&#39;one_vs_rest_train&#39;</span><span class="p">,</span>
                                                        <span class="s2">&quot;one_vs_rest_predict&quot;</span><span class="p">],</span>
                                                       <span class="n">descr</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;train&#39;</span><span class="p">,</span> <span class="s1">&#39;binning&#39;</span><span class="p">,</span> <span class="s1">&#39;feature_select&#39;</span><span class="p">]:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">train_input_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s train_input_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">train_input_table</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">train_input_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s train_input_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">train_input_namespace</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;train&quot;</span><span class="p">,</span> <span class="s2">&quot;predict&quot;</span><span class="p">,</span> <span class="s2">&quot;cross_validation&quot;</span><span class="p">]:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">model_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s model_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">model_table</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">model_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s model_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">model_namespace</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="o">==</span> <span class="s1">&#39;predict&#39;</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_input_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s predict_input_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_input_table</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_input_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s predict_input_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_input_namespace</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_output_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s predict_output_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_output_table</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_output_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s predict_output_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_output_namespace</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;train&quot;</span><span class="p">,</span> <span class="s2">&quot;predict&quot;</span><span class="p">,</span> <span class="s2">&quot;cross_validation&quot;</span><span class="p">]:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_result_partition</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s predict_result_partition </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_result_partition</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">evaluation_output_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s evaluation_output_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">evaluation_output_table</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">evaluation_output_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s evaluation_output_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">evaluation_output_namespace</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="o">==</span> <span class="s1">&#39;cross_validation&#39;</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">data_input_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s data_input_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">data_input_table</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">data_input_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s data_input_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">data_input_namespace</span><span class="p">))</span>

            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">n_splits</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s n_splits </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">n_splits</span><span class="p">))</span>
            <span class="k">elif</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">n_splits</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s n_splits must be greater or equal to 1&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">intersect_data_output_table</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">intersect_data_output_table</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s intersect_data_output_table </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">intersect_data_output_table</span><span class="p">))</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">intersect_data_output_namespace</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">intersect_data_output_namespace</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;workflow param&#39;s intersect_data_output_namespace </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                        <span class="n">workflow_param</span><span class="o">.</span><span class="n">intersect_data_output_namespace</span><span class="p">))</span>

        <span class="n">DataIOParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">dataio_param</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">work_mode</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;workflow param&#39;s work_mode </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">workflow_param</span><span class="o">.</span><span class="n">work_mode</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">work_mode</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;workflow param&#39;s work_mode must be 0 (represent to standalone mode) or 1 (represent to cluster mode)&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">workflow_param</span><span class="o">.</span><span class="n">method</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;train&quot;</span><span class="p">,</span> <span class="s2">&quot;predict&quot;</span><span class="p">,</span> <span class="s2">&quot;cross_validation&quot;</span><span class="p">]:</span>
            <span class="n">PredictParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">predict_param</span><span class="p">)</span>
            <span class="n">EvaluateParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">evaluate_param</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">workflow_param</span><span class="o">.</span><span class="n">one_vs_rest</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;workflow_param param&#39;s one_vs_rest </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">workflow_param</span><span class="o">.</span><span class="n">one_vs_rest</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish workerflow parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="InitParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.InitParamChecker">[docs]</a><span class="k">class</span> <span class="nc">InitParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="InitParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.InitParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">init_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">init_method</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Init param&#39;s init_method </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">init_method</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">init_param</span><span class="o">.</span><span class="n">init_method</span> <span class="o">=</span> <span class="n">init_param</span><span class="o">.</span><span class="n">init_method</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">init_param</span><span class="o">.</span><span class="n">init_method</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;random_uniform&#39;</span><span class="p">,</span> <span class="s1">&#39;random_normal&#39;</span><span class="p">,</span> <span class="s1">&#39;ones&#39;</span><span class="p">,</span> <span class="s1">&#39;zeros&#39;</span><span class="p">,</span> <span class="s1">&#39;const&#39;</span><span class="p">]:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;Init param&#39;s init_method </span><span class="si">{}</span><span class="s2"> not supported, init_method should in &#39;random_uniform&#39;,&quot;</span>
                    <span class="s2">&quot; &#39;random_normal&#39; &#39;ones&#39;, &#39;zeros&#39; or &#39;const&#39;&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">init_method</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">init_const</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;int&#39;</span><span class="p">,</span> <span class="s1">&#39;float&#39;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Init param&#39;s init_const </span><span class="si">{}</span><span class="s2"> not supported, should be int or float type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">init_const</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">fit_intercept</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s1">&#39;bool&#39;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;Init param&#39;s fit_intercept </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">init_param</span><span class="o">.</span><span class="n">fit_intercept</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish init parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="LogisticParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.LogisticParamChecker">[docs]</a><span class="k">class</span> <span class="nc">LogisticParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="LogisticParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.LogisticParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">logistic_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;logistic_param&#39;s&quot;</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">penalty</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s penalty </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">penalty</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">logistic_param</span><span class="o">.</span><span class="n">penalty</span> <span class="o">=</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">penalty</span><span class="o">.</span><span class="n">upper</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">penalty</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;L1&#39;</span><span class="p">,</span> <span class="s1">&#39;L2&#39;</span><span class="p">,</span> <span class="s1">&#39;NONE&#39;</span><span class="p">]:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;logistic_param&#39;s penalty not supported, penalty should be &#39;L1&#39;, &#39;L2&#39; or &#39;none&#39;&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">eps</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;float&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s eps </span><span class="si">{}</span><span class="s2"> not supported, should be float type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">eps</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">alpha</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;float&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s alpha </span><span class="si">{}</span><span class="s2"> not supported, should be float type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">alpha</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">optimizer</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s optimizer </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">optimizer</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">logistic_param</span><span class="o">.</span><span class="n">optimizer</span> <span class="o">=</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">optimizer</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">optimizer</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;sgd&#39;</span><span class="p">,</span> <span class="s1">&#39;rmsprop&#39;</span><span class="p">,</span> <span class="s1">&#39;adam&#39;</span><span class="p">,</span> <span class="s1">&#39;adagrad&#39;</span><span class="p">]:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;logistic_param&#39;s optimizer not supported, optimizer should be&quot;</span>
                    <span class="s2">&quot; &#39;sgd&#39;, &#39;rmsprop&#39;, &#39;adam&#39; or &#39;adagrad&#39;&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">batch_size</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s batch_size </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">batch_size</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">batch_size</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="p">:</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">batch_size</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> \
                    <span class="ow">or</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">batch_size</span> <span class="o">&lt;</span> <span class="n">consts</span><span class="o">.</span><span class="n">MIN_BATCH_SIZE</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be larger than 10 or &quot;</span>
                                         <span class="s2">&quot;-1 represent for all data&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">batch_size</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;float&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s learning_rate </span><span class="si">{}</span><span class="s2"> not supported, should be float type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">logistic_param</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">))</span>

        <span class="n">InitParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">init_param</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">max_iter</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s max_iter </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">max_iter</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">max_iter</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s max_iter must be greater or equal to 1&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">converge_func</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s converge_func </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">logistic_param</span><span class="o">.</span><span class="n">converge_func</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">logistic_param</span><span class="o">.</span><span class="n">converge_func</span> <span class="o">=</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">converge_func</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
            <span class="k">if</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">converge_func</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;diff&#39;</span><span class="p">,</span> <span class="s1">&#39;abs&#39;</span><span class="p">]:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                    <span class="s2">&quot;logistic_param&#39;s converge_func not supported, converge_func should be&quot;</span>
                    <span class="s2">&quot; &#39;diff&#39; or &#39;abs&#39;&quot;</span><span class="p">)</span>

        <span class="n">EncryptParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">encrypt_param</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">re_encrypt_batches</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;int&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s re_encrypt_batches </span><span class="si">{}</span><span class="s2"> not supported, should be int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">logistic_param</span><span class="o">.</span><span class="n">re_encrypt_batches</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">logistic_param</span><span class="o">.</span><span class="n">re_encrypt_batches</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s re_encrypt_batches must be greater or equal to 0&quot;</span><span class="p">)</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">model_path</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s model_path </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">logistic_param</span><span class="o">.</span><span class="n">model_path</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">table_name</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;str&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s table_name </span><span class="si">{}</span><span class="s2"> not supported, should be str type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">logistic_param</span><span class="o">.</span><span class="n">table_name</span><span class="p">))</span>

        <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">logistic_param</span><span class="o">.</span><span class="n">party_weight</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s1">&#39;float&#39;</span><span class="p">]:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                <span class="s2">&quot;logistic_param&#39;s party_weight </span><span class="si">{}</span><span class="s2"> not supported, should be &#39;int&#39; or &#39;float&#39;&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                    <span class="n">logistic_param</span><span class="o">.</span><span class="n">party_weight</span><span class="p">))</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish logistic parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="FeatureBinningParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FeatureBinningParamChecker">[docs]</a><span class="k">class</span> <span class="nc">FeatureBinningParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="FeatureBinningParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FeatureBinningParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">binning_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;hetero binning param&#39;s&quot;</span>
        <span class="n">check_string</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">binning_param</span><span class="o">.</span><span class="n">method</span> <span class="o">=</span> <span class="n">binning_param</span><span class="o">.</span><span class="n">method</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
        <span class="n">check_valid_value</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">method</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">QUANTILE</span><span class="p">])</span>
        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">compress_thres</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">head_size</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">check_decimal_float</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">error</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">bin_num</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">check_defined_type</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">cols</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">,</span> <span class="s1">&#39;int&#39;</span><span class="p">,</span> <span class="s1">&#39;RepeatedScalarContainer&#39;</span><span class="p">])</span>
        <span class="n">check_open_unit_interval</span><span class="p">(</span><span class="n">binning_param</span><span class="o">.</span><span class="n">adjustment_factor</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="FeatureSelectionParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FeatureSelectionParamChecker">[docs]</a><span class="k">class</span> <span class="nc">FeatureSelectionParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="FeatureSelectionParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FeatureSelectionParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;hetero feature selection param&#39;s&quot;</span>
        <span class="n">feature_param</span><span class="o">.</span><span class="n">method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">method</span><span class="p">,</span>
                                                      <span class="p">[</span><span class="s1">&#39;fit&#39;</span><span class="p">,</span> <span class="s1">&#39;fit_transform&#39;</span><span class="p">,</span> <span class="s1">&#39;transform&#39;</span><span class="p">],</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">check_defined_type</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">filter_method</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">])</span>

        <span class="k">for</span> <span class="n">idx</span><span class="p">,</span> <span class="n">method</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">filter_method</span><span class="p">):</span>
            <span class="n">method</span> <span class="o">=</span> <span class="n">method</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
            <span class="n">check_valid_value</span><span class="p">(</span><span class="n">method</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s2">&quot;unique_value&quot;</span><span class="p">,</span> <span class="s2">&quot;iv_value_thres&quot;</span><span class="p">,</span> <span class="s2">&quot;iv_percentile&quot;</span><span class="p">,</span>
                                              <span class="s2">&quot;coefficient_of_variation_value_thres&quot;</span><span class="p">,</span>
                                              <span class="s2">&quot;outlier_cols&quot;</span><span class="p">])</span>
            <span class="n">feature_param</span><span class="o">.</span><span class="n">filter_method</span><span class="p">[</span><span class="n">idx</span><span class="p">]</span> <span class="o">=</span> <span class="n">method</span>
        <span class="k">if</span> <span class="s2">&quot;iv_value_thres&quot;</span> <span class="ow">in</span> <span class="n">feature_param</span><span class="o">.</span><span class="n">filter_method</span> <span class="ow">and</span> <span class="s2">&quot;iv_percentile&quot;</span> <span class="ow">in</span> <span class="n">feature_param</span><span class="o">.</span><span class="n">filter_method</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Two iv methods should not exist at the same time.&quot;</span><span class="p">)</span>

        <span class="n">check_defined_type</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">select_cols</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">,</span> <span class="s1">&#39;int&#39;</span><span class="p">])</span>

        <span class="n">check_boolean</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">local_only</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">UniqueValueParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">unique_param</span><span class="p">)</span>
        <span class="n">IVValueSelectionParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">iv_value_param</span><span class="p">)</span>
        <span class="n">IVPercentileSelectionParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">iv_percentile_param</span><span class="p">)</span>
        <span class="n">CoeffOfVarSelectionParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">coe_param</span><span class="p">)</span>
        <span class="n">OutlierColsSelectionParamChecker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">outlier_param</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="UniqueValueParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.UniqueValueParamChecker">[docs]</a><span class="k">class</span> <span class="nc">UniqueValueParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="UniqueValueParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.UniqueValueParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;Unique value param&#39;s&quot;</span>
        <span class="n">check_positive_number</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">eps</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="IVValueSelectionParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.IVValueSelectionParamChecker">[docs]</a><span class="k">class</span> <span class="nc">IVValueSelectionParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="IVValueSelectionParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.IVValueSelectionParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;IV selection param&#39;s&quot;</span>
        <span class="n">check_positive_number</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">value_threshold</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="IVPercentileSelectionParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.IVPercentileSelectionParamChecker">[docs]</a><span class="k">class</span> <span class="nc">IVPercentileSelectionParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="IVPercentileSelectionParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.IVPercentileSelectionParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;IV selection param&#39;s&quot;</span>
        <span class="n">check_decimal_float</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">percentile_threshold</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="CoeffOfVarSelectionParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.CoeffOfVarSelectionParamChecker">[docs]</a><span class="k">class</span> <span class="nc">CoeffOfVarSelectionParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="CoeffOfVarSelectionParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.CoeffOfVarSelectionParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;Coff of Variances param&#39;s&quot;</span>
        <span class="n">check_positive_number</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">value_threshold</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="OutlierColsSelectionParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.OutlierColsSelectionParamChecker">[docs]</a><span class="k">class</span> <span class="nc">OutlierColsSelectionParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="OutlierColsSelectionParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.OutlierColsSelectionParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">feature_param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;Outlier Filter param&#39;s&quot;</span>
        <span class="n">check_decimal_float</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">percentile</span><span class="p">,</span> <span class="n">descr</span><span class="p">)</span>
        <span class="n">check_defined_type</span><span class="p">(</span><span class="n">feature_param</span><span class="o">.</span><span class="n">upper_threshold</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;float&#39;</span><span class="p">,</span> <span class="s1">&#39;int&#39;</span><span class="p">])</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="OneHotEncoderParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.OneHotEncoderParamChecker">[docs]</a><span class="k">class</span> <span class="nc">OneHotEncoderParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="OneHotEncoderParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.OneHotEncoderParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">param</span><span class="p">):</span>
        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;One-hot encoder param&#39;s&quot;</span>
        <span class="n">check_defined_type</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">cols</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">,</span> <span class="s1">&#39;int&#39;</span><span class="p">])</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="FTLModelParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FTLModelParamChecker">[docs]</a><span class="k">class</span> <span class="nc">FTLModelParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="FTLModelParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FTLModelParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">ftl_model_param</span><span class="p">):</span>
        <span class="n">model_param_descr</span> <span class="o">=</span> <span class="s2">&quot;ftl model param&#39;s &quot;</span>
        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">ftl_model_param</span><span class="o">.</span><span class="n">max_iter</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;max_iter&quot;</span><span class="p">)</span>
        <span class="n">check_positive_number</span><span class="p">(</span><span class="n">ftl_model_param</span><span class="o">.</span><span class="n">eps</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;eps&quot;</span><span class="p">)</span>
        <span class="n">check_positive_number</span><span class="p">(</span><span class="n">ftl_model_param</span><span class="o">.</span><span class="n">alpha</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;alpha&quot;</span><span class="p">)</span>
        <span class="n">check_boolean</span><span class="p">(</span><span class="n">ftl_model_param</span><span class="o">.</span><span class="n">is_encrypt</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;is_encrypt&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="LocalModelParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.LocalModelParamChecker">[docs]</a><span class="k">class</span> <span class="nc">LocalModelParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="LocalModelParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.LocalModelParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">local_model_param</span><span class="p">):</span>
        <span class="n">model_param_descr</span> <span class="o">=</span> <span class="s2">&quot;local model param&#39;s &quot;</span>
        <span class="k">if</span> <span class="n">local_model_param</span><span class="o">.</span><span class="n">input_dim</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">local_model_param</span><span class="o">.</span><span class="n">input_dim</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;input_dim&quot;</span><span class="p">)</span>
        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">local_model_param</span><span class="o">.</span><span class="n">encode_dim</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;encode_dim&quot;</span><span class="p">)</span>
        <span class="n">check_open_unit_interval</span><span class="p">(</span><span class="n">local_model_param</span><span class="o">.</span><span class="n">learning_rate</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;learning_rate&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="FTLDataParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FTLDataParamChecker">[docs]</a><span class="k">class</span> <span class="nc">FTLDataParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="FTLDataParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FTLDataParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="p">):</span>
        <span class="n">model_param_descr</span> <span class="o">=</span> <span class="s2">&quot;ftl data model param&#39;s &quot;</span>
        <span class="k">if</span> <span class="n">ftl_data_param</span><span class="o">.</span><span class="n">file_path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">check_string</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">file_path</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;file_path&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">ftl_data_param</span><span class="o">.</span><span class="n">num_samples</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">num_samples</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;num_samples&quot;</span><span class="p">)</span>

        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">n_feature_guest</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;n_feature_guest&quot;</span><span class="p">)</span>
        <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">n_feature_host</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;n_feature_host&quot;</span><span class="p">)</span>
        <span class="n">check_boolean</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">balanced</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;balanced&quot;</span><span class="p">)</span>
        <span class="n">check_boolean</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">is_read_table</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;is_read_table&quot;</span><span class="p">)</span>
        <span class="n">check_open_unit_interval</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">overlap_ratio</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;overlap_ratio&quot;</span><span class="p">)</span>
        <span class="n">check_open_unit_interval</span><span class="p">(</span><span class="n">ftl_data_param</span><span class="o">.</span><span class="n">guest_split_ratio</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;guest_split_ratio&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="FTLValidDataParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FTLValidDataParamChecker">[docs]</a><span class="k">class</span> <span class="nc">FTLValidDataParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="FTLValidDataParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.FTLValidDataParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">ftl_valid_data_param</span><span class="p">):</span>
        <span class="n">model_param_descr</span> <span class="o">=</span> <span class="s2">&quot;ftl validation data model param&#39;s &quot;</span>
        <span class="k">if</span> <span class="n">ftl_valid_data_param</span><span class="o">.</span><span class="n">file_path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">check_string</span><span class="p">(</span><span class="n">ftl_valid_data_param</span><span class="o">.</span><span class="n">file_path</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;file_path&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">ftl_valid_data_param</span><span class="o">.</span><span class="n">num_samples</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">check_positive_integer</span><span class="p">(</span><span class="n">ftl_valid_data_param</span><span class="o">.</span><span class="n">num_samples</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;num_samples&quot;</span><span class="p">)</span>

        <span class="n">check_boolean</span><span class="p">(</span><span class="n">ftl_valid_data_param</span><span class="o">.</span><span class="n">is_read_table</span><span class="p">,</span> <span class="n">model_param_descr</span> <span class="o">+</span> <span class="s2">&quot;is_read_table&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="ScaleParamChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.ScaleParamChecker">[docs]</a><span class="k">class</span> <span class="nc">ScaleParamChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="ScaleParamChecker.check_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.ScaleParamChecker.check_param">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">check_param</span><span class="p">(</span><span class="n">scale_param</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">method</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s method&quot;</span>
            <span class="n">scale_param</span><span class="o">.</span><span class="n">method</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">method</span><span class="p">,</span>
                                                        <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">MINMAXSCALE</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">STANDARDSCALE</span><span class="p">],</span>
                                                        <span class="n">descr</span><span class="p">)</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s mode&quot;</span>
        <span class="n">scale_param</span><span class="o">.</span><span class="n">mode</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">mode</span><span class="p">,</span>
                                                  <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">NORMAL</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">CAP</span><span class="p">],</span>
                                                  <span class="n">descr</span><span class="p">)</span>

        <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s area&quot;</span>
        <span class="n">scale_param</span><span class="o">.</span><span class="n">area</span> <span class="o">=</span> <span class="n">check_and_change_lower</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">area</span><span class="p">,</span>
                                                  <span class="p">[</span><span class="n">consts</span><span class="o">.</span><span class="n">ALL</span><span class="p">,</span> <span class="n">consts</span><span class="o">.</span><span class="n">COL</span><span class="p">],</span>
                                                  <span class="n">descr</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">area</span> <span class="o">==</span> <span class="n">consts</span><span class="o">.</span><span class="n">ALL</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">feat_lower</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">feat_lower</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;scale param&#39;s feat_lower </span><span class="si">{}</span><span class="s2"> not supported, should be float or int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">scale_param</span><span class="o">.</span><span class="n">feat_lower</span><span class="p">))</span>

            <span class="k">if</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">feat_upper</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">feat_upper</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;scale param&#39;s feat_upper </span><span class="si">{}</span><span class="s2"> not supported, should be float or int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">scale_param</span><span class="o">.</span><span class="n">feat_upper</span><span class="p">))</span>

            <span class="k">if</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">out_lower</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">out_lower</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;scale param&#39;s out_lower </span><span class="si">{}</span><span class="s2"> not supported, should be float or int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">scale_param</span><span class="o">.</span><span class="n">out_lower</span><span class="p">))</span>

            <span class="k">if</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">out_upper</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">out_upper</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">]:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;scale param&#39;s out_upper </span><span class="si">{}</span><span class="s2"> not supported, should be float or int type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                            <span class="n">scale_param</span><span class="o">.</span><span class="n">out_upper</span><span class="p">))</span>
        <span class="k">elif</span> <span class="n">scale_param</span><span class="o">.</span><span class="n">area</span> <span class="o">==</span> <span class="n">consts</span><span class="o">.</span><span class="n">COL</span><span class="p">:</span>
            <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s feat_lower&quot;</span>
            <span class="n">check_defined_type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">feat_lower</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">])</span>

            <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s feat_upper&quot;</span>
            <span class="n">check_defined_type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">feat_upper</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">])</span>

            <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s out_lower&quot;</span>
            <span class="n">check_defined_type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">out_lower</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">])</span>

            <span class="n">descr</span> <span class="o">=</span> <span class="s2">&quot;scale param&#39;s out_upper&quot;</span>
            <span class="n">check_defined_type</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">out_upper</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;list&#39;</span><span class="p">])</span>

        <span class="n">check_boolean</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">with_mean</span><span class="p">,</span> <span class="s2">&quot;scale_param with_mean&quot;</span><span class="p">)</span>
        <span class="n">check_boolean</span><span class="p">(</span><span class="n">scale_param</span><span class="o">.</span><span class="n">with_std</span><span class="p">,</span> <span class="s2">&quot;scale_param with_std&quot;</span><span class="p">)</span>

        <span class="n">LOGGER</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s2">&quot;Finish scale parameter check!&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="check_string"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_string">[docs]</a><span class="k">def</span> <span class="nf">check_string</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;str&quot;</span><span class="p">]:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be string type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>


<div class="viewcode-block" id="check_positive_integer"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_positive_integer">[docs]</a><span class="k">def</span> <span class="nf">check_positive_integer</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be positive integer&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>


<div class="viewcode-block" id="check_positive_number"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_positive_number">[docs]</a><span class="k">def</span> <span class="nf">check_positive_number</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">,</span> <span class="s2">&quot;int&quot;</span><span class="p">,</span> <span class="s2">&quot;long&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;=</span> <span class="mi">0</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be positive numeric&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>


<div class="viewcode-block" id="check_decimal_float"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_decimal_float">[docs]</a><span class="k">def</span> <span class="nf">check_decimal_float</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be a float number in range [0, 1]&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>


<div class="viewcode-block" id="check_boolean"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_boolean">[docs]</a><span class="k">def</span> <span class="nf">check_boolean</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s2">&quot;bool&quot;</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be bool type&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">))</span></div>


<div class="viewcode-block" id="check_open_unit_interval"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_open_unit_interval">[docs]</a><span class="k">def</span> <span class="nf">check_open_unit_interval</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;float&quot;</span><span class="p">]</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&lt;=</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">param</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; should be a numeric number between 0 and 1 exclusively&quot;</span><span class="p">)</span></div>


<div class="viewcode-block" id="check_valid_value"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_valid_value">[docs]</a><span class="k">def</span> <span class="nf">check_valid_value</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="n">valid_values</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">param</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">valid_values</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> is not supported, it should be in </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_values</span><span class="p">))</span></div>


<div class="viewcode-block" id="check_defined_type"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_defined_type">[docs]</a><span class="k">def</span> <span class="nf">check_defined_type</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">descr</span><span class="p">,</span> <span class="n">types</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">types</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be one of </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">types</span><span class="p">))</span></div>


<span class="c1"># Used when param is a string.</span>
<div class="viewcode-block" id="check_and_change_lower"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.check_and_change_lower">[docs]</a><span class="k">def</span> <span class="nf">check_and_change_lower</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_list</span><span class="p">,</span> <span class="n">descr</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
    <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">param</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="o">!=</span> <span class="s1">&#39;str&#39;</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be one of </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_list</span><span class="p">))</span>

    <span class="n">lower_param</span> <span class="o">=</span> <span class="n">param</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">lower_param</span> <span class="ow">in</span> <span class="n">valid_list</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">lower_param</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="n">descr</span> <span class="o">+</span> <span class="s2">&quot; </span><span class="si">{}</span><span class="s2"> not supported, should be one of </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">valid_list</span><span class="p">))</span></div>


<div class="viewcode-block" id="AllChecker"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.AllChecker">[docs]</a><span class="k">class</span> <span class="nc">AllChecker</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">config_path</span><span class="p">,</span> <span class="n">param_restricted_path</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">config_path</span> <span class="o">=</span> <span class="n">config_path</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">param_restricted_path</span> <span class="o">=</span> <span class="n">param_restricted_path</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">func</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;ge&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_greater_equal_than</span><span class="p">,</span>
                     <span class="s2">&quot;le&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_less_equal_than</span><span class="p">,</span>
                     <span class="s2">&quot;in&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_in</span><span class="p">,</span>
                     <span class="s2">&quot;not_in&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_not_in</span><span class="p">,</span>
                     <span class="s2">&quot;range&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_range</span>
                     <span class="p">}</span>

<div class="viewcode-block" id="AllChecker.check_all"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.AllChecker.check_all">[docs]</a>    <span class="k">def</span> <span class="nf">check_all</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">DataIOParam</span><span class="p">,</span> <span class="n">DataIOParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">EncryptParam</span><span class="p">,</span> <span class="n">EncryptParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">EncryptedModeCalculatorParam</span><span class="p">,</span> <span class="n">EncryptedModeCalculatorParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">SampleParam</span><span class="p">,</span> <span class="n">SampleParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">EvaluateParam</span><span class="p">,</span> <span class="n">EvaluateParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">ObjectiveParam</span><span class="p">,</span> <span class="n">ObjectiveParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">PredictParam</span><span class="p">,</span> <span class="n">PredictParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">WorkFlowParam</span><span class="p">,</span> <span class="n">WorkFlowParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">InitParam</span><span class="p">,</span> <span class="n">InitParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">EncodeParam</span><span class="p">,</span> <span class="n">EncodeParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">IntersectParam</span><span class="p">,</span> <span class="n">IntersectParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">LogisticParam</span><span class="p">,</span> <span class="n">LogisticParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">DecisionTreeParam</span><span class="p">,</span> <span class="n">DecisionTreeParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">BoostingTreeParam</span><span class="p">,</span> <span class="n">BoostingTreeParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">FTLModelParam</span><span class="p">,</span> <span class="n">FTLModelParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">LocalModelParam</span><span class="p">,</span> <span class="n">LocalModelParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">FTLDataParam</span><span class="p">,</span> <span class="n">FTLDataParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">FTLValidDataParam</span><span class="p">,</span> <span class="n">FTLValidDataParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">FeatureBinningParam</span><span class="p">,</span> <span class="n">FeatureBinningParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">FeatureSelectionParam</span><span class="p">,</span> <span class="n">FeatureSelectionParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">ScaleParam</span><span class="p">,</span> <span class="n">ScaleParamChecker</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_check</span><span class="p">(</span><span class="n">param</span><span class="o">.</span><span class="n">OneVsRestParam</span><span class="p">,</span> <span class="n">OneVsRestChecker</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="nf">_check</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">Param</span><span class="p">,</span> <span class="n">Checker</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        check if parameters define in Param Ojbect is valid or not.</span>
<span class="sd">            validity of parameters decide by the following two ways:</span>
<span class="sd">                1. match the definition in ParamObject, which will be check in checker</span>
<span class="sd">                2. match the param restriction of user definition, define in workflow/conf/param_validation.json</span>

<span class="sd">        Parameters</span>
<span class="sd">        ----------  </span>
<span class="sd">        Param: object, define in federatedml/param/param.py</span>

<span class="sd">        Checker: object, define in this module, see above</span>

<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">param_obj</span> <span class="o">=</span> <span class="n">Param</span><span class="p">()</span>
        <span class="n">param_obj</span> <span class="o">=</span> <span class="n">ParamExtract</span><span class="o">.</span><span class="n">parse_param_from_config</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">config_path</span><span class="p">)</span>
        <span class="n">Checker</span><span class="o">.</span><span class="n">check_param</span><span class="p">(</span><span class="n">param_obj</span><span class="p">)</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">param_restricted_path</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">param_restricted_path</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fin</span><span class="p">:</span>
                <span class="n">validation_json</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">fin</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>

            <span class="n">param_classes</span> <span class="o">=</span> <span class="p">[</span><span class="n">class_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">class_info</span> <span class="ow">in</span> <span class="n">inspect</span><span class="o">.</span><span class="n">getmembers</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">inspect</span><span class="o">.</span><span class="n">isclass</span><span class="p">)]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">validate_restricted_param</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="n">validation_json</span><span class="p">,</span> <span class="n">param_classes</span><span class="p">)</span>

<div class="viewcode-block" id="AllChecker.validate_restricted_param"><a class="viewcode-back" href="../../../federatedml.util.html#federatedml.util.param_checker.AllChecker.validate_restricted_param">[docs]</a>    <span class="k">def</span> <span class="nf">validate_restricted_param</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param_obj</span><span class="p">,</span> <span class="n">validation_json</span><span class="p">,</span> <span class="n">param_classes</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Validate the param restriction of user definition recursively.</span>
<span class="sd">            It will only validation parameters define both in param_obj and validation_json</span>

<span class="sd">        Parameters</span>
<span class="sd">        ---------- </span>
<span class="sd">        param_obj: object, parameter object define in federatedml/param/param.py</span>

<span class="sd">        validation_json: dict, parameter restriction of user-define.</span>

<span class="sd">        param_classes: list, all object define in federatedml/param/param.py</span>
<span class="sd">  </span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">default_section</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">param_obj</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span>
        <span class="n">var_list</span> <span class="o">=</span> <span class="n">param_obj</span><span class="o">.</span><span class="vm">__dict__</span>

        <span class="k">for</span> <span class="n">variable</span> <span class="ow">in</span> <span class="n">var_list</span><span class="p">:</span>
            <span class="n">attr</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="n">variable</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">attr</span><span class="p">)</span><span class="o">.</span><span class="vm">__name__</span> <span class="ow">in</span> <span class="n">param_classes</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">validate_restricted_param</span><span class="p">(</span><span class="n">attr</span><span class="p">,</span> <span class="n">validation_json</span><span class="p">,</span> <span class="n">param_classes</span><span class="p">)</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">default_section</span> <span class="ow">in</span> <span class="n">validation_json</span> <span class="ow">and</span> <span class="n">variable</span> <span class="ow">in</span> <span class="n">validation_json</span><span class="p">[</span><span class="n">default_section</span><span class="p">]:</span>
                    <span class="n">validation_dict</span> <span class="o">=</span> <span class="n">validation_json</span><span class="p">[</span><span class="n">default_section</span><span class="p">][</span><span class="n">variable</span><span class="p">]</span>
                    <span class="n">value</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">param_obj</span><span class="p">,</span> <span class="n">variable</span><span class="p">)</span>
                    <span class="n">value_legal</span> <span class="o">=</span> <span class="kc">False</span>

                    <span class="k">for</span> <span class="n">op_type</span> <span class="ow">in</span> <span class="n">validation_dict</span><span class="p">:</span>
                        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="p">[</span><span class="n">op_type</span><span class="p">](</span><span class="n">value</span><span class="p">,</span> <span class="n">validation_dict</span><span class="p">[</span><span class="n">op_type</span><span class="p">]):</span>
                            <span class="n">value_legal</span> <span class="o">=</span> <span class="kc">True</span>
                            <span class="k">break</span>

                    <span class="k">if</span> <span class="ow">not</span> <span class="n">value_legal</span><span class="p">:</span>
                        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                            <span class="s2">&quot;Plase check runtime conf, </span><span class="si">{}</span><span class="s2"> = </span><span class="si">{}</span><span class="s2"> does not match user-parameter restriction&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                                <span class="n">variable</span><span class="p">,</span> <span class="n">value</span><span class="p">))</span></div>

    <span class="k">def</span> <span class="nf">_greater_equal_than</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">limit</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="o">&gt;=</span> <span class="n">limit</span> <span class="o">-</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span>

    <span class="k">def</span> <span class="nf">_less_equal_than</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">limit</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="o">&lt;=</span> <span class="n">limit</span> <span class="o">+</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span>

    <span class="k">def</span> <span class="nf">_range</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">ranges</span><span class="p">):</span>
        <span class="n">in_range</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">for</span> <span class="n">left_limit</span><span class="p">,</span> <span class="n">right_limit</span> <span class="ow">in</span> <span class="n">ranges</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">value</span> <span class="o">&gt;=</span> <span class="n">left_limit</span> <span class="o">-</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span> <span class="ow">and</span> <span class="n">value</span> <span class="o">&lt;=</span> <span class="n">right_limit</span> <span class="o">+</span> <span class="n">consts</span><span class="o">.</span><span class="n">FLOAT_ZERO</span><span class="p">:</span>
                <span class="n">in_range</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">break</span>

        <span class="k">return</span> <span class="n">in_range</span>

    <span class="k">def</span> <span class="nf">_in</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">right_value_list</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">right_value_list</span>

    <span class="k">def</span> <span class="nf">_not_in</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">wrong_value_list</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">value</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">wrong_value_list</span></div>
</pre></div>

           </div>
           
          </div>
          <footer>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2019, FATE_TEAM

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>